<template>
  <div class="leader" v-if="dataList.bookList.length > 0">
    <el-card shadow="hover">
      <div class="box">
        <div class="header">
          <div class="title">
            <div class="info">{{dataList.name}}</div>
            <div class="intro">分榜热门</div>
          </div>
          <div class="more" @click="handleToLibrary">更多></div>
        </div>
        <div class="first">
          <div class="num">1</div>
          <div class="info-box">
            <div class="info">
              <div
                class="title"
                @click="handleToChapter(dataList.bookList[0].id)"
              >{{dataList.bookList[0].name}}</div>
              <div class="detail">{{dataList.bookList[0].intro}}</div>
            </div>
            <div class="img">
              <el-image :src="dataList.bookList[0].image" fit="fill" lazy>
                <div slot="error">
                  <img src="http://foglake.sanye666.top/images/default-covor.jpg" alt />
                </div>
              </el-image>
            </div>
          </div>
        </div>
        <div class="other" v-for="(item, index) in dataList.bookList.slice(1,10)" :key="index">
          <div :class="(index + 2) == 2 ?'second':(index + 2) == 3 ? 'third': 'nomarl'">{{index+2}}</div>
          <div class="info-box">
            <div class="title" @click="handleToChapter(item.id)">{{item.name}}</div>
            <div class="sort">
              <svg-icon
                :icon-class="Math.ceil(Math.random() * 10) > 5 ? 'top_arrow' : Math.ceil(Math.random() * 10) > 5 ? 'bottom_arrow' : 'leader_middle'"
              />
            </div>
          </div>
        </div>
      </div>
    </el-card>
  </div>
</template>

<script>
export default {
  name: "Leaderboard",
  props: { dataList: Object },
  data() {
    return {};
  },
  watch: {
    dataList(val) {
      this.dataList = val;
    }
  },
  methods: {
    handleToChapter(id) {
      this.$router.push({
        path: "/chapter",
        query: { id }
      });
    },
    handleToLibrary() {
      this.$router.push({
        path: "/library",
        query: { type: this.dataList.id }
      });
    }
  }
};
</script>

<style lang="scss" scoped>
.leader {
  width: 385px;
  background: rgba(255, 255, 255, 1);
  border-radius: 12px;
  margin-bottom: 20px;
  .box {
    padding: 36px 34px 40px 34px;
    .header {
      display: flex;
      flex-direction: columns;
      justify-content: space-between;
      border-bottom: 1px solid rgba(6, 27, 65, 0.05);
      margin-bottom: 20px;
      .title {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        .info {
          font-size: 20px;
          font-family: MicrosoftYaHeiSemibold;
          font-weight: 600;
          color: rgba(6, 27, 65, 1);
          line-height: 24px;
          opacity: 0.65;
          margin-bottom: 10px;
        }
        .intro {
          font-size: 12px;
          font-family: MicrosoftYaHei;
          font-weight: 400;
          color: rgba(6, 27, 65, 1);
          line-height: 14px;
          opacity: 0.45;
          margin-bottom: 18px;
        }
      }
      .more {
        font-size: 12px;
        font-family: MicrosoftYaHei;
        font-weight: 400;
        color: rgba(146, 200, 255, 1);
        line-height: 14px;
        height: 100%;
        cursor: pointer;
      }
    }
    .first {
      display: flex;
      justify-content: space-between;
      .num {
        width: 16px;
        height: 16px;
        background: rgba(255, 130, 130, 1);
        border-radius: 50%;
        font-size: 12px;
        font-family: MicrosoftYaHeiSemibold;
        font-weight: 600;
        color: rgba(255, 255, 255, 1);
        margin-top: -1px;
      }
      .info-box {
        width: 280px;
        border-bottom: 1px solid rgba(6, 27, 65, 0.05);
        display: flex;
        justify-content: space-between;
        padding-bottom: 22px;
        .info {
          display: flex;
          flex-direction: column;
          align-items: flex-start;
          .title {
            font-size: 14px;
            font-family: MicrosoftYaHeiSemibold;
            font-weight: 600;
            color: rgba(6, 27, 65, 0.45);
            line-height: 14px;
            margin-bottom: 16px;
            cursor: pointer;
            height: 15px;
            overflow: hidden;
            text-overflow: ellipsis;
            display: -webkit-box;
            -webkit-line-clamp: 1;
            -webkit-box-orient: vertical;
          }
          .title:hover {
            color: rgba(146, 200, 255, 1);
          }
          .detail {
            font-size: 12px;
            font-family: MicrosoftYaHei;
            font-weight: 400;
            color: rgba(6, 27, 65, 1);
            line-height: 14px;
            opacity: 0.25;
            text-align: left;
            cursor: pointer;
            overflow: hidden;
            text-overflow: ellipsis;
            display: -webkit-box;
            -webkit-line-clamp: 4;
            -webkit-box-orient: vertical;
          }
        }
        .img {
        }
      }
    }
    .other {
      display: flex;
      justify-content: space-between;
      padding-top: 21px;
      align-items: flex-start;
      .second {
        width: 16px;
        height: 16px;
        border-radius: 50%;
        font-size: 12px;
        font-family: MicrosoftYaHeiSemibold;
        font-weight: 600;
        color: rgba(255, 255, 255, 1);
        margin-top: -1px;
        background: rgba(254, 163, 103, 1);
      }
      .third {
        width: 16px;
        height: 16px;
        border-radius: 50%;
        font-size: 12px;
        font-family: MicrosoftYaHeiSemibold;
        font-weight: 600;
        color: rgba(255, 255, 255, 1);
        margin-top: -1px;
        background: rgba(255, 217, 88, 1);
      }
      .nomarl {
        width: 16px;
        height: 16px;
        border-radius: 50%;
        font-size: 12px;
        font-family: MicrosoftYaHeiSemibold;
        font-weight: 600;
        color: rgba(255, 255, 255, 1);
        margin-top: -1px;
        background: rgba(146, 200, 255, 1);
      }
      .info-box {
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 280px;
        padding-bottom: 21px;
        border-bottom: 1px solid rgba(6, 27, 65, 0.05);
        .title {
          font-size: 14px;
          font-family: MicrosoftYaHei;
          font-weight: 400;
          color: rgba(6, 27, 65, 0.45);
          line-height: 14px;
          cursor: pointer;
          overflow: hidden;
          text-overflow: ellipsis;
          white-space: nowrap;
        }
        .title:hover {
          color: rgba(146, 200, 255, 1);
        }
        .sort {
          font-size: 12px;
        }
      }
    }
  }
}

.leader:hover {
  transform: translateY(-3px);
}

.box .other:last-child .info-box {
  border-bottom: none;
  padding-bottom: 0;
}
</style>